package com.lwb.oss.controller;

import com.lwb.commonutils.Row;
import com.lwb.oss.service.OssService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/eduOss/fileOss")
@CrossOrigin
public class OssController {

    @Autowired
    private OssService ossService;

    //1. 上传头像
    @ApiOperation("上传头像")
    @PostMapping
    public Row uploadOssFile(MultipartFile file){
        System.out.println(file);
        //获取上传文件
        String url = ossService.uploadFileAvatar(file);
        return Row.SUCCESS().data("url",url);
    }
}
